<%
local dsp = require "luci.dispatcher"
-%>

<script type="text/javascript">
	//<![CDATA[
	var trojan_users_status = document.getElementsByClassName('trojan_users_status');
	for(var i = 0; i < trojan_users_status.length; i++) {
		var id = trojan_users_status[i].parentElement.parentElement.parentElement.id;
		id = id.substr(id.lastIndexOf("-") + 1);
		XHR.poll(1,'<%=dsp.build_url("admin/vpn/trojan_server/users_status")%>', {
				index: i,
				id: id
			},
			function(x, result) {
				trojan_users_status[result.index].setAttribute("style","font-weight:bold;");
				trojan_users_status[result.index].setAttribute("color",result.status ? "green":"red");
				trojan_users_status[result.index].innerHTML = (result.status ? '✓' : 'X');
			}
		);
	}
	//]]>
</script>